package com.smart.controller;

import com.smart.common.ResultVo;
import com.smart.entity.Article;
import com.smart.entity.Chat;
import com.smart.entity.Feedback;
import com.smart.entity.Work;
import com.smart.service.ChatService;
import com.smart.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/admin")
public class AdminWmsController {

    @Autowired
    WorkService workService;

    @Autowired
    ChatService chatService;

    @GetMapping("/wms/all")
    public ResultVo WorkAll(Integer currentPage,Integer pageSize) {
        Map<String, Object> stringObjectMap = workService.WorkAll(currentPage,pageSize);
        return ResultVo.ok().data("item",stringObjectMap);
    }

    @GetMapping("/wms/list")
    public ResultVo WorkList(Integer currentPage,Integer pageSize) {
        Map<String, Object> stringObjectMap = workService.WorkList(currentPage,pageSize);
        return ResultVo.ok().data("item",stringObjectMap);
    }

    @GetMapping("/wms/pending")
    public ResultVo WorkPending(Integer currentPage,Integer pageSize) {
        Map<String, Object> stringObjectMap = workService.WorkPending(currentPage,pageSize);
        return ResultVo.ok().data("item",stringObjectMap);
    }

    @GetMapping("/wms/processed")
    public ResultVo WorkProcessed(Integer currentPage,Integer pageSize) {
        Map<String, Object> stringObjectMap = workService.WorkProcessed(currentPage,pageSize);
        return ResultVo.ok().data("item",stringObjectMap);
    }

    @GetMapping("/wms/closed")
    public ResultVo WorkClosed(Integer currentPage,Integer pageSize) {
        Map<String, Object> stringObjectMap = workService.WorkClosed(currentPage,pageSize);
        return ResultVo.ok().data("item",stringObjectMap);
    }

    @GetMapping("/wms/delete")
    public ResultVo WorkDelete(Integer id) {
        Integer result = workService.WorkDelete(id);
        return ResultVo.ok().data("item",result);
    }

    @GetMapping("/wms/findwork")
    public ResultVo WorkFind(Integer id) {
        Work result = workService.WorkFind(id);
        return ResultVo.ok().data("item", result);
    }

    @PostMapping("/wms/work/edit")
    public ResultVo WorkEdit(Work work) {
        Integer result = workService.WorkEdit(work);
        return ResultVo.ok().data("item", result);
    }

    @GetMapping("/wms/work/chat")
    public ResultVo WorkChat(Integer id) {
        Work result = workService.WorkChat(id);
        return ResultVo.ok().data("item", result);
    }

    @PostMapping("/wms/work/chat/add")
    public ResultVo WorkChatAdd( Chat chat) {
        Integer result = chatService.WorkChatAdd(chat);
        return ResultVo.ok().data("item", result);
    }

    @GetMapping("/wms/work/chat/all")
    public ResultVo WorkChatAll(Integer work_id) {
        List<Chat> result = chatService.WorkChatAll(work_id);
        return ResultVo.ok().data("item", result);
    }
}
